﻿using M_Ingredient.API.Application.Command.IngredientCommand;
using M_Ingredient.Repository.Interface;
using MediatR;

namespace M_Ingredient.API.Application.CommandHandler.IngredientCommandHandler
{
    public class IngredientUpdateCommandHandler : IRequestHandler<IngredientUpdateCommand, int>
    {
        protected readonly IIngredientRepository ingredientRepository;

        public IngredientUpdateCommandHandler(IIngredientRepository ingredientRepository)
        {
            this.ingredientRepository = ingredientRepository;
        }

        public  async Task<int> Handle(IngredientUpdateCommand request, CancellationToken cancellationToken)
        {
            return await ingredientRepository.UpdateAsync(request);
        }
    }
}
